﻿<%@ Page Language="C#" AutoEventWireup="true" MasterPageFile="~/Layout.Master" CodeBehind="addReservation.aspx.cs" Inherits="PT.pages.addReservation" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
    </asp:Content>
<asp:Content ID="cpContent" ContentPlaceHolderID="cpContent" runat="server">
    <asp:DetailsView ID="DetailsView2" runat="server" AutoGenerateRows="False" 
        BorderStyle="None" CssClass="grid" DataKeyNames="id" 
        DataSourceID="SqlDataSource1" Height="50px" Width="274px">
        <RowStyle Wrap="True" />
        <FieldHeaderStyle Font-Strikeout="False" ForeColor="#FF9900" />
        <Fields>
            <asp:BoundField DataField="name" HeaderText="Nazwa" SortExpression="name" />
            <asp:BoundField DataField="size" HeaderText="Rozmiar" SortExpression="size" 
                DataFormatString="{0} os./pokój" />
            <asp:BoundField DataField="cost" HeaderText="Cena za dobę" 
                SortExpression="cost" DataFormatString="{0} zł" />
        </Fields>
    </asp:DetailsView>
    <asp:SqlDataSource ID="SqlDataSource1" runat="server" 
        ConnectionString="<%$ ConnectionStrings:HotelConnectionString1 %>" 
        InsertCommand="INSERT INTO Reservation(startDate, endDate, bookerName, telephone, room_id) VALUES (@startDate, @endDate, @bookerName, @telephone, @room_id)" 
        OldValuesParameterFormatString="original_{0}" 
        SelectCommand="SELECT * FROM Rooms WHERE (id = @room_id)">
        <SelectParameters>
            <asp:QueryStringParameter Name="room_id" QueryStringField="id" Type="Int32" />
        </SelectParameters>
        <InsertParameters>
            <asp:Parameter Name="startDate" />
            <asp:Parameter Name="endDate" />
            <asp:Parameter Name="bookerName" />
            <asp:Parameter Name="telephone" />
            <asp:QueryStringParameter Name="room_id" QueryStringField="id" Type="Int32"/>
        </InsertParameters>
    </asp:SqlDataSource>
    <br />
    <div id="in_line">
    <asp:Label ID="lbStartHour" runat="server" Text="Godzina rozpoczęcia"></asp:Label>
    <asp:TextBox ID="tbStartHour" runat="server" BorderStyle="Solid" 
        BorderWidth="1px" Height="28px" Width="142px"></asp:TextBox>
    <asp:Calendar ID="CalendarStart" runat="server" BorderStyle="None" 
        FirstDayOfWeek="Monday" 
        Width="273px" onselectionchanged="CalendarStart_SelectionChanged">
        <DayStyle ForeColor="#FF9900" />
    </asp:Calendar>
    </div>
    <div id="in_line">
    <asp:Label ID="lbEndHour" runat="server" Text="Godzina zakończenia"></asp:Label>
    <asp:TextBox ID="tbEndHour" runat="server" BorderStyle="Solid" 
        BorderWidth="1px" Height="28px" Width="142px"></asp:TextBox>
    <asp:Calendar ID="CalendarEnd" runat="server" BorderStyle="None" 
        FirstDayOfWeek="Monday" 
        Width="273px" onselectionchanged="CalendarEnd_SelectionChanged">
        <DayStyle ForeColor="#FF9900" />
    </asp:Calendar>
    </div>
    <br />
    <asp:Label ID="lbError" runat="server" Text="" ForeColor="Red"></asp:Label>
    <br />
    <asp:Label ID="lbWho" runat="server" Text="Rezerwujący"></asp:Label>
    <asp:TextBox
        ID="tbWho" runat="server" BorderStyle="Solid" BorderWidth="1" Height="28" Width="142"></asp:TextBox>
    <asp:RequiredFieldValidator ID="valWho" runat="server" 
        ErrorMessage="Kto rezerwuję pokój?" ControlToValidate="tbWho"></asp:RequiredFieldValidator>
    <br />
    <asp:Label ID="lbTel" runat="server" Text="Telefon"></asp:Label>
    <asp:TextBox
        ID="tbTel" runat="server" BorderStyle="Solid" BorderWidth="1" Height="28" Width="142"></asp:TextBox>
    <br />
    <br />
    <asp:Button ID="btInsert" runat="server" Text="Dodaj rezerwację" 
        BorderColor="#FF9900" BorderStyle="Solid" BorderWidth="1px" 
        onclick="btInsert_Click" />
    <br />
    </asp:Content>
